home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-15 | 4.3 KB | 107 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UVolume.h
- // ETO20 MacApp 3.3.1, MPW 3.4.1
- // Copyright ©1996 Conrad Kopala
- // Twist Down Lists version 2.0a0 7/15/96
- //----------------------------------------------------------------------------------------
-
- #ifndef __UVOLUME__
- #define __UVOLUME__
-
- // MacApp
- #ifndef __UOBJECT__
- #include "UObject.h"
- #endif
-
- // Toolbox
- #ifndef __ALIASES__
- #include "Aliases.h"
- #endif
-
- #ifndef __STANDARDFILE__
- #include "StandardFile.h"
- #endif
-
- //ANSI
- //None
-
-
- // UVolume parallels UFile. It would have been preferable to use TFile but that
- // doesn't work.
-
- // TApplication::CanOpenDocument compares aFile -> fFileType with the fileTypes
- // the application is allowed to open. In this case, the application is allowed to
- // open files of type 'disk'. When a file is specified, using one or another of the
- // TFile::Specifies methods, StandardFileReply and SFReply which these methods rely
- // on do not return a fileType of 'disk.' In other words, itsReply.sfType does not
- // return 'disk' but 'garbage' instead. The net effect is that CanOpenDocument
- // returns false and nothing happens. One could, of course, override CanOpenDocument
- // and make it return TRUE.
- //
- // But, TFile::SpecifyWithAlias uses TFile::GetFinderInfo to get the fileType
- // using FSpGetFInfo and since junk is returned, SpecifyWithAlias defaults to a
- // fileType of 'TEXT' and again, nothing happens. I wanted the user to be able to
- // drop a volume on the application icon or its alias and open the volume.
- //
- // Finally, TFile contains methods that are not appropriate to a volume. For example,
- // CreateFile, CreateDataFork, CreateResourceFork, OpenFile, etc. I don't think it is
- // good design to drag along all those methods, so subclassing TFile is not a good
- // idea. If TFile were subclassed, many methods, for safety's sake, would have to be
- // overridden to do nothing or you would have to research each one to make sure nothing
- // bad would happen.
- //
- // When working within a framework such as MacApp, the only appropriate ways of modifying
- // its behavior are to subclass and override or to create a new object. One thing you really
- // don't want to do is modify the framework code. In this case, it seemed best to create a
- // new object, TVolume.
- //
- // By choosing to create TVolume, methods of TApplication were affected. Specifically,
- // methods involved with opening old files: DoMakeFile, ChooseFile, CanOpenDocument, and
- // OpenOld. But, they are based on TFile and I needed methods based on TVolume. I could
- // have put the substitute methods DoMakeVolume, ChooseVolume, CanOpenVolume, and
- // OpenVolume in TTwistDownApp but, for one thing, I wanted to keep them together.
- // For another, to avoid confusion, I wanted their names to use the word, volume instead of
- // file. Therefore, I created MVolumeBasedApp and used multiple inheritance.
- //
- // See UVolumeBasedApp.h for more.
- //----------------------------------------------------------------------------------------
- // TVolume
- //----------------------------------------------------------------------------------------
-
- class TVolume : public TObject
- {
- MA_DECLARE_CLASS;
-
- public:
-
- FSSpec fFileSpec; // volume/ directory/filename
- OSType fFileType; // file type
- OSType fCreator; // creator ID
-
- TVolume::TVolume();
- void TVolume::IVolume(OSType itsCreator);
- virtual ~TVolume();
-
- Boolean TVolume::IsHFSVolume();
- void TVolume::Specify(const FSSpec& theVolume);
- void TVolume::SpecifyWithStandardFileReply(const StandardFileReply& itsReply);
- OSErr TVolume::SpecifyWithSFReply(const SFReply& itsReply);
- OSErr TVolume::SpecifyWithAlias(AliasHandle alias);
- OSErr TVolume::SpecifyWithTrio(short volRefNum, long dirID, const CStr63& name);
- OSErr TVolume::GetAlias(AliasHandle& alias);
- OSErr TVolume::GetCatInfo(CInfoPBRec& cInfo);
- void TVolume::GetName(CStr31& name);
- short TVolume::GetVolRefNum();
- Boolean TVolume::IsSameVolume(TVolume* aVolume);
- };
-
- //----------------------------------------------------------------------------------------
- // Global function declarations
- //----------------------------------------------------------------------------------------
-
- extern TVolume* NewVolume(OSType itsCreator);
- // A convenience function. Create a TVolume, initialize it, and return a reference to
- // it. Signals Failure if it cannot allocate the object.
-
-
- #endif